<?php
/**
 * Created by PhpStorm OF yuyi.
 * User: YUYI
 * Date: 2018/5/14 0014
 * Time: 下午 4:09
 * Administrator
 */

namespace app\common\model;


use app\common\service\UserService;
use think\Model;

class BaseModel extends Model
{
    protected static function init()
    {
//        $user = UserService::getCurrentUserInfo();
//        if (!$user){
//            return false;
//        }
//        $th = new static();
//        self::event('after_insert',function ($model) use ($user,$th){
//            $pk = $th->getPk();
//            SysLog::create(['userid'=>$user['userId'],'operationType'=>1,'association'=>$th->class.':'.(isset($model->$pk)?$model->$pk:'')]);
//        });
//        self::event('before_update',function ($model) use ($user,$th){
//            $pk = $th->getPk();
//            SysLog::create(['userid'=>$user['userId'],'operationType'=>2,'association'=>$th->class.':'.(isset($model->$pk)?$model->$pk:'')]);
//        });
//        self::event('before_delete',function ($model) use ($user,$th){
//            $pk = $th->getPk();
//            SysLog::create(['userid'=>$user['userId'],'operationType'=>3,'association'=>$th->class.':'.(isset($model->$pk)?$model->$pk:'')]);
//        });
//        unset($th);
    }
}